<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace App\Components;
use App\Constants\CebApi;
use App\Components\HttpRequest;
/**
 * Description of CebApiRequest
 *
 * @author xueb
 */
class CebApiRequest{
    private $_host = '';
    private $_params = null;

    /**
     * @param $int_Api
     * @param $map_Params
     * @return HttpRequestResult
     */
    public function invoke($int_Api, $map_Params) {
        $this->_host = config('api.ceb.host');
        $this->_params = $map_Params;
        switch ($int_Api){
            case CebApi::CHANNEL_INFO:
                return $this->channelInfo();
            case CebApi::CHANNEL_DAILY:
                return $this->channelDaily();
            case CebApi::MEDIA_LIST:
                return $this->mediaList();
            case CebApi::ADVERTISEMENT_ADD:
                return $this->advertisementAdd();
            case CebApi::ADVERTISEMENT_EDIT:
                return $this->advertisementEdit();
            case CebApi::ADVERTISEMENT_SHOW:
                return $this->advertisementShow();
            case CebApi::ADVERTISEMENT_LIST:
                return $this->advertisementList();
            case CebApi::ADVERTISEMENT_SHOWPLACE:
                return $this->advertisementShowPlaces();
            case CebApi::ADVERTISEMENT_TYPES:
                return $this->advertisementTypes();
            case CebApi::SUBJECT_LIST:
                return $this->subjectList();
            case CebApi::ACTIVITY_LIST:
                return $this->activityList();
            case CebApi::VERSION_LIST:
                return $this->versionList();
            case CebApi::USER_FILTERS:
                return $this->userFilters();
            case CebApi::MESSAGE_SEND:
                return $this->messageSend();
            case CebApi::VIDEO_LIST:
                return $this->videoList();
            case CebApi::USER_NEW:
                return $this->userNew();
            case CebApi::DEALS_LIST:
                return $this->dealList();
            default:
                abort(501,'调用未实现的超额宝接口:' . $int_Api);
        }
    }
    
    private function channelInfo(){
        return HttpRequest::get($this->_host, 'channels/show',$this->_params);
    }
    
    private function channelDaily(){
        return HttpRequest::get($this->_host, 'channels/daily', $this->_params);
    }
    
    private function mediaList(){
        return HttpRequest::get($this->_host, 'media_list', $this->_params);
    }
    private function advertisementAdd(){
        return HttpRequest::post($this->_host, 'advertisements/add', $this->_params);
    }
    
    private function advertisementEdit(){
        return HttpRequest::post($this->_host, 'advertisements/edit', $this->_params);
    }
    
    private function advertisementShow(){
        return HttpRequest::get($this->_host, 'advertisements/show', $this->_params);
    }
    
    private function advertisementList(){
        return HttpRequest::get($this->_host, 'advertisements/list', $this->_params);
    }
    
    private function advertisementShowPlaces(){
        return HttpRequest::get($this->_host, 'advertisements/show_places', $this->_params);
    }
    
    private function advertisementTypes(){
        return HttpRequest::get($this->_host, 'advertisements/types', $this->_params);
    }
    
    private function subjectList(){
        return HttpRequest::get($this->_host, 'subjects/list', $this->_params);
    }
    
    private function activityList(){
        return HttpRequest::get($this->_host, 'activities/list', $this->_params);
    }
    
    private function versionList(){
        return HttpRequest::get($this->_host, 'versions/list', $this->_params);
    }
    
    private function userFilters(){
        return HttpRequest::get($this->_host, 'users/filters', $this->_params);
    }
    
    private function messageSend(){
        return HttpRequest::post($this->_host, 'messages/send', $this->_params);
    }
    
    private function videoList(){
        return HttpRequest::get($this->_host, 'videos/list', $this->_params);
    }

    private function userNew(){
        return HttpRequest::get($this->_host, 'users/new', $this->_params);
    }

    private function dealList(){
        return HttpRequest::get($this->_host, 'deals/list', $this->_params);
    }
}
